Skip to content

REGR: loc.setitem losing index name when df was empty before #45623

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 26, 2022

Conversation

phofl
Copy link
Member

@phofl phofl commented Jan 25, 2022

@phofl phofl added Indexing Related to indexing on series/frames, not to indexes themselves Regression Functionality that used to work in a prior pandas version labels Jan 25, 2022
@phofl phofl added this to the 1.4.1 milestone Jan 25, 2022
@@ -2018,6 +2018,8 @@ def _setitem_with_indexer_missing(self, indexer, value):
# internals.concat logic
df = value.to_frame().T
df.index = [indexer]
# error: "List[Any]" has no attribute "name"
df.index.name = self.obj.index.name # type: ignore[attr-defined]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm this is actually modifying the indexer i think.

maybe
df.index = pd.Index([indexer], name=self.obj.index.name)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, changed

@jreback jreback merged commit 3aa2ed4 into pandas-dev:main Jan 26, 2022
meeseeksmachine pushed a commit to meeseeksmachine/pandas that referenced this pull request Jan 26, 2022
jreback pushed a commit that referenced this pull request Jan 27, 2022
@phofl phofl deleted the 45621 branch January 28, 2022 10:19
yehoshuadimarsky pushed a commit to yehoshuadimarsky/pandas that referenced this pull request Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Indexing Related to indexing on series/frames, not to indexes themselves Regression Functionality that used to work in a prior pandas version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: 1.4.0 does not preserve initially empty Index and appended by loc assignment.
2 participants